//
//  ZClubsListHeaderView.m
//  WeClubs
//
//  Created by 花花 on 2017/6/21.
//  Copyright © 2017年 Zed. All rights reserved.
//

#import "ZClubsListHeaderView.h"

@implementation ZClubsListHeaderView

- (instancetype)initWithFrame:(CGRect)frame{

    if (self == [super initWithFrame:frame]) {
    
        self.backgroundColor = [UIColor whiteColor];
        [self initUI];
    }
    
    return self;

}

- (void)initUI{

    NSArray *titles = @[@"姓名",@"年级",@"部门",@"职位"];
    
    for (int i= 0; i<titles.count; i++){
     
        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(i *(Z_SCREEN_WIDTH/titles.count),0,Z_SCREEN_WIDTH/titles.count,40)];
        btn.tag = i;
        if (i ==0 ) {
            btn.selected = YES;
        }
        [btn setTitle:titles[i] forState:UIControlStateNormal];
        [btn setTitleColor:NORMAL_COLOR forState:UIControlStateNormal];
        btn.titleLabel.textAlignment = NSTextAlignmentCenter;
        [btn setTitleColor:HIGHTLIGHT_COLOR forState:UIControlStateSelected];
        btn.titleLabel.font = [UIFont systemFontOfSize:15];
        [btn addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:btn];
    }


}

-(void)clickAction:(UIButton *)btn{
    
    if (self.handlerBtnClickCallBack) {
        self.handlerBtnClickCallBack(btn);
    }

}
@end


@implementation ZClubSectionHeaderView


- (instancetype)init{
    self = [super init];
    if (self) {
        [self initUI];
        [self initConstraint];
    }
    return self;
}

- (void)initUI{

    _titleLabel = [[UILabel alloc]init];
    
    _titleLabel.font = [UIFont systemFontOfSize:13];
    
    [self addSubview:_titleLabel];
    
    _allBtn = [[UIButton alloc]init];
    _allBtn.hidden = YES;
    
    [_allBtn addTarget:self action:@selector(clickAllBtn) forControlEvents:UIControlEventTouchUpInside];
    [_allBtn setTitle:@"全选" forState:UIControlStateNormal];
    [_allBtn setTitleColor:HIGHTLIGHT_COLOR forState:UIControlStateNormal];
    _allBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:_allBtn];

}


- (void)initConstraint{

    Z_WEAK_SELF;
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).offset(15);
        make.centerY.equalTo(weakSelf.mas_centerY);
    }];
    
    [_allBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.mas_right).offset(-15);
        make.centerY.equalTo(weakSelf.mas_centerY);
    }];

}

-(void)clickAllBtn{
    if(self.callback){
        self.callback();
    }


}


@end
